
import paddle
print('飞桨框架内置模型：', paddle.vision.models.__all__)


mobilenetv2 = paddle.vision.models.MobileNetV2(num_classes=4)
model = paddle.nn.Sequential(
                mobilenetv2,paddle.nn.Softmax())
model = paddle.Model(model)

import paddle
from dataset import handPointsDataset


#数据集
train_dataset = handPointsDataset()

# 设置优化器
optim = paddle.optimizer.Adam(parameters=model.parameters())
# 设置损失函数
#loss_fn = paddle.nn.CrossEntropyLoss()
loss_fn = paddle.nn.MSELoss()


model.prepare(optimizer=optim,
              loss=loss_fn,
              metrics=paddle.metric.Accuracy())


model.fit(train_dataset,
          epochs=100,
          batch_size=256,
          save_dir="checkpoint/",
          save_freq=10,
          verbose=1)



eval_result = model.evaluate(train_dataset, verbose=1)

print(eval_result)


